package cn.iocoder.mall.order.biz.mq;

import cn.iocoder.common.framework.constant.CommonConstant;
import cn.iocoder.mall.order.api.OrderService;
import cn.iocoder.mall.order.api.dto.ExpireOrderDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/***
 *@author yinxucun
 *@date 2019-11-22 18:31 
 */
@Service
@Slf4j
@RocketMQMessageListener(topic = CommonConstant.ORDER_EXPIRE, consumerGroup = "mall_order_expire")
public class ExpireOrderConsumer implements RocketMQListener<ExpireOrderDTO> {

    @Autowired
    private OrderService orderService;

    @Override
    public void onMessage(ExpireOrderDTO message) {
        orderService.closeExpireOrder(message.getOrderId());
        log.info("关闭超时订单，id:"+message.getOrderId());
    }
}
